//
//  RW_FuncView.m
//  SleepApp
//
//  Created by chuangqi on 2021/3/30.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_FuncView.h"
#import "RW_FuncItemCollectionViewCell.h"
@interface RW_FuncView ()
@property (nonatomic,strong) WLCollectionView *wlclass_collection_view;
@end
@implementation RW_FuncView
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = HexColor(@"f6f6f6");
        [self addSubview:self.wlclass_collection_view];
        [self.wlclass_collection_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsZero);
        }];
    }
    return self;
}

#pragma mark -- 数据绑定
/** 初始化数据 */
-(void)initData{
    [self.wlclass_view_model getViewSuccess:^(NSArray<WLBaseCollectionViewLayerSection *> *response) {
        [self.wlclass_collection_view setAllSection:response];
    } fail:^(NSError *error) {
        
    }];
}
#pragma mark -- WLCollectionView 代理
- (void)wl_collectionView:(UICollectionView *)collectionView
               layerModel:(WLBaseCollectionViewLayerModel *)layerModel
             layerRowData:(id)rowData
             didIndexPath:(NSIndexPath *)indexPath{
    if ([rowData isKindOfClass:RW_FuncItemCollectionViewCellModel.class]){
        RW_FuncItemCollectionViewCellModel *model = rowData;
        if (model.players_Type == Players_Type_Player){
            [RW_PlayerViewController pushSingleFromVc:[self viewController_wl]];
        } else if (model.players_Type == Players_Type_Mixed){
            [RW_MixedViewController pushSingleFromVc:[self viewController_wl]];
        } else if (model.players_Type == Players_Type_Default){
            
        }
    }
}

#pragma mark -- 懒加载
-(RW_FuncViewModel *)wlclass_view_model{
    if (!_wlclass_view_model){
        _wlclass_view_model = [[RW_FuncViewModel alloc]init];
    }
    return _wlclass_view_model;
}
-(WLCollectionView *)wlclass_collection_view{
    if (!_wlclass_collection_view){
        _wlclass_collection_view = [WLCollectionView initWithVerticalDelegate:self];
    }
    return _wlclass_collection_view;
}

@end
